package com.guichun.oop.base;

import sun.rmi.runtime.Log;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Logger;

/**
 * @author guichun
 * @version 1.0.0
 * @ClassName AllTest.java
 * @email onebigbai@icloud.com
 * @Description 大部分的测试类
 * @createTime 2021-03-01
 */
public class AllTest {
    public static void main(String[] args) throws NoSuchFieldException, NoSuchMethodException {
//        StudentToPerson student = new StudentToPerson();
//        student.run();

//        Stu stu = new Stu();
//        stu.run();

//        Person person = new Person("熊猫", 12);
//        Person person1 = new Person("四川", 13);
//        System.out.println(Person.number1 = 12);
//        System.out.println(Person.number1 = 13);
//        System.out.println("person = " + person.toString());
//        System.out.println("person1 = " + person1.toString());

//        String s = "\tbaiguilin\r\n";
//        System.out.println("s.trim() = " + s.trim());
//        System.out.println("s.isEmpty() = " + s.isEmpty());
//        System.out.println("s.replace(\"guilin\", \"guichun\") = " + s.replace("guilin", "guichun"));

//        StringBuilder sb = new StringBuilder(1024);
//        for (int i = 0; i < 1000; i++) {
//            sb.append(",");
//            sb.append(i);
//            System.out.println("i = " + i);
//        }

//        Person person = new Person("guichun", 18);
//        Person person1 = new Person("guichun", 18);
//        HashMap hash1 = new HashMap();
//        hash1.put(person, "我是第一个");
//        System.out.println(hash1.get(person1));
//        System.out.println("person = " + person);
//        System.out.println("person1 = " + person1);
//        person = com.guichun.oop.base.Person@29453f44
//        person1 = com.guichun.oop.base.Person@5cad8086

        //NumberFormatException 数值格式错误
//        Person person = new Person("guichun", 18);
//        person.run();

        //logging日志
//        Logger logger = Logger.getGlobal();
//        logger.info("信息：start process...");
//        logger.warning("警告...");
//        logger.fine("ignored");
//        logger.severe("process will be terminated...");

        //使用Commons Logging
//        Log log = LogFactory.getLog(AllTest);
//        Class<Person> personClass = Person.class;
//        System.out.println(personClass.getMethod("test"));

        //动态代理
//        InvocationHandler handler = new InvocationHandler() {
//            @Override
//            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//                System.out.println("method = " + method);
//                if (method.getName().equals("run")) {
//                    System.out.println("good" + args[0]);
//                }
//                return null;
//            }
//        };
//        PersonsImpl personsImpl = (PersonsImpl) Proxy.newProxyInstance(
//                Personsss.class.getClassLoader(),
//                new Class[]{PersonsImpl.class},
//                handler
//        );
//        personsImpl.run("guichun");

        // 泛型
        ArrayList list = new ArrayList<>();
        list.add(12);
        list.add("guichun");

    }

}
